home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Games / Arashi 1.1.1 / source code / Game Source / jam src / GamePause.new.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-22  |  4.3 KB  |  204 lines  |  [TEXT/KAHL]

  1. /*/
  2.      Project Arashi: GamePause.new.c
  3.      Major release: Version 1.1d2, 9/5/95
  4.  
  5.      Last modification: Monday, March 22, 1993, 17:31
  6.      Created: Wednesday, October 9, 1991, 23:45
  7.  
  8.      Copyright © 1991-1993, Juri Munkki
  9. /*/
  10.  
  11. #include <VA.h>
  12. #include "STORM.h"
  13. #include "GamePause.h"
  14. #include "PlayOptions.h"
  15. #include "loadsave.h"
  16. #include "heroflags.h"
  17.  
  18. extern    int                ScoretoBeatIndex;    /* mz */
  19.  
  20. extern    EventRecord        Event;
  21. extern    WindowPtr        BackdropWind;
  22.  
  23. extern    Player            Hero;        /* mz */
  24.  
  25. extern    Point            CenterMouse;
  26. extern    void            GetSetMouse(Point *where);
  27.  
  28. extern    int                PlayKeyCodes[];        /*    right, left, fire, zap    */
  29.  
  30. #define    PAUSEDIALOG    129
  31. enum    {    EndPauseButton = 1, RememberKeysButton,
  32.             RotateRightRadio = 5, RotateLeftRadio,
  33.             FireRadio, SuperZapRadio, SaveGame};
  34.  
  35. /* typedef struct{
  36.         int        lvnum;
  37.         int        lvType;
  38.         long    score;
  39.         int        lives;
  40.         long    freelives;
  41.         int        ShowFuseScores;
  42.         int        RestartMode;
  43.         int        Flags;
  44.         int        NumZaps;
  45.         } **GameRecHand, GameRec; */
  46.         
  47. void    GamePauseCleanup()
  48. {
  49.     Point        NoWhere;
  50.     long        EndTime;
  51.  
  52.     NoWhere = CenterMouse;
  53.     GetSetMouse(&NoWhere);
  54.     Delay(5,&EndTime);
  55.  
  56.     VA.color = 0;
  57.     RedrawField();
  58.     RedrawSpikes();
  59.     DisplayLives();
  60. }
  61.  
  62. void    GamePause(cleanup)
  63. int        cleanup;
  64. {
  65.     DialogPtr    PauseDialog;
  66.     DialogPtr    DialogHit;
  67.     int            ItemHit;
  68.     int            ColorStatus = -1;
  69.     int            KeyToChange;
  70.     long        KeyRecord[4];
  71.     int            WhichKey;
  72.     int            k; /* mz */
  73.     int            i;    /* mz */
  74.     
  75.     HideWindow(BackdropWind);
  76.     HideWindow(VA.window);
  77.     VARestoreColors();
  78.  
  79.     PauseDialog = GetNewDialog(PAUSEDIALOG,0,(WindowPtr)-1);
  80.     CenterWindow(PauseDialog);
  81.     ShowWindow(PauseDialog);
  82.     ShowCursor();
  83.     ItemHit = 0;
  84.     KeyToChange = 1;
  85.     SetItemValue(PauseDialog, RotateLeftRadio, 1);
  86.     
  87.     if(cleanup != GameRunning)
  88.         SetItemEnable(PauseDialog, SaveGame, 255);
  89.     
  90.     do
  91.     {    if(((*(*((GDHandle)VA.device))->gdPMap)->pixelSize == 8) != ColorStatus)
  92.         {    ColorStatus = !ColorStatus;
  93.             SetItemEnable(PauseDialog, EndPauseButton, ColorStatus ? 0 : 255);
  94.         }
  95.         
  96.         
  97.         GetKeys(&KeyRecord);
  98.         if(KeyRecord[0] || KeyRecord[1] || KeyRecord[2] || KeyRecord[3])
  99.         {    
  100.             for(WhichKey=0;WhichKey<128;WhichKey++)
  101.             {    if(BitTst(&KeyRecord,WhichKey))
  102.                 {    WhichKey+=1000;
  103.                 }
  104.             }
  105.             
  106.             if(WhichKey > 1000)
  107.             {    PlayKeyCodes[KeyToChange] = WhichKey-1001;
  108.                 SetItemValue(PauseDialog, RotateRightRadio+KeyToChange, 0);
  109.                 SetItemValue(PauseDialog, RotateRightRadio+KeyToChange, 1);
  110.             }
  111.         }
  112.         
  113.         if(GetNextEvent(everyEvent,&Event))
  114.         {    if(IsDialogEvent(&Event) && Event.what != keyDown)
  115.             {    if(!DialogSelect(&Event,&DialogHit,&ItemHit))
  116.                     ItemHit=0;
  117.                 else
  118.                 {    switch(ItemHit)
  119.                     {    case RotateRightRadio:
  120.                         case RotateLeftRadio:
  121.                         case FireRadio:
  122.                         case SuperZapRadio:
  123.                             SetItemValue(PauseDialog, RotateRightRadio+KeyToChange, 0);
  124.                             KeyToChange = ItemHit - RotateRightRadio;
  125.                             SetItemValue(PauseDialog, RotateRightRadio+KeyToChange, 1);
  126.                             break;
  127.                         case RememberKeysButton:
  128.                             {    Handle    TheKeys;
  129.                             
  130.                                 TheKeys = GetResource('KEYS',128);
  131.                                 BlockMove(PlayKeyCodes,*TheKeys,8);
  132.                                 ChangedResource(TheKeys);
  133.                                 WriteResource(TheKeys);
  134.                                 
  135.                             }
  136.                             break;
  137.                         case SaveGame:
  138.                                 SaveGameF();
  139.                             break;
  140.                     }
  141.                 }
  142.             }
  143.         }
  144.     } while(ItemHit != EndPauseButton);
  145.     
  146.     HideCursor();
  147.     ShowWindow(BackdropWind);
  148.  
  149.     DisposDialog(PauseDialog);
  150.     ShowWindow(VA.window);
  151.                 
  152.     RectRgn(VA.window->visRgn,&VA.window->portRect);
  153.     SetPort(VA.window);
  154.  
  155.     {
  156.         /* PaintRect(&VA.window->portRect);             fix small screen pause bug */
  157.     }
  158.     {
  159.         int        oldBackTasks = PlayOptions->noBackgroundTasks;
  160.         
  161.         PlayOptions->noBackgroundTasks = FALSE;
  162.         for(i=0;i<50;i++)
  163.         {    GameEvent();
  164.         }
  165.         PlayOptions->noBackgroundTasks = oldBackTasks;
  166.     }
  167.  
  168.     VAEraseBuffer();
  169.     
  170.     if((cleanup != LevelSelectRunning) && (cleanup != TitlesRunning))
  171.     {
  172.         VA.segmscale=(VA.frame.bottom>>6);            /* mz */
  173.         if(VA.segmscale<1) VA.segmscale=1;
  174.         k=VA.color;
  175.         VA.color=BG2;
  176.         VADrawNumber(ThisLevel.lvNumber,VA.frame.right/2-VA.segmscale-3,VA.segmscale*2+4);
  177.         VA.color=k;
  178.     }
  179.     
  180.     
  181.     switch(cleanup)
  182.     {    case GameRunning:
  183.             GamePauseCleanup();
  184.                 break;
  185.         case FlythruRunning:
  186.             DisplayLives();                    /* fix (mz) */
  187.         case LevelSelectRunning:
  188.             {    Point        NoWhere;
  189.                 long        EndTime;
  190.             
  191.                 NoWhere = CenterMouse;
  192.                 GetSetMouse(&NoWhere);
  193.                 Delay(5,&EndTime);
  194.             }
  195.             break;
  196.     }
  197.     
  198.     VACatchUp();
  199.     VAStep();
  200.     
  201.     Event.what = 0;
  202.     Event.modifiers = btnState;
  203. }
  204.